package formbeans;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class ChangePasswordForm extends FormBean{
	private String oldpassword;
	private String newpassword;
	
	public String getOldpassword() {
		return oldpassword;
	}
	public void setOldpassword(String oldpassword) {
		this.oldpassword = trimAndConvert(oldpassword,"<>\"");
	}
	public String getNewpassword() {
		return newpassword;
	}
	public void setNewpassword(String newpassword) {
		this.newpassword = trimAndConvert(newpassword,"<>\"");
	}
	public List<String> checkChangePasswordFormErrors(){
		List<String> errors = new ArrayList<String>();
		
		if(oldpassword == null || oldpassword.length() == 0){
			errors.add("old password is required");
		} else if (oldpassword.length() >= 255) {
			errors.add("old password is too long.");
		}
		if(newpassword == null || newpassword.length() == 0){
			errors.add("new password is required");
		} else if (newpassword.length() >= 20) {
			errors.add("new password's length is 1-20, please re-enter.");
		}
		//if there is no error, it should be null
		return errors;
	}
	
}
